﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
using System.Reflection;

namespace CANMonitor
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
			// 导出相关的dll文件
			string dll_file = Directory.GetCurrentDirectory() + "\\ControlCAN.dll";
			//if (File.Exists(dll_file) == false)
			//{
			//    Stream sm = Assembly.GetExecutingAssembly().GetManifestResourceStream("CANMonitor.ControlCAN.dll");
			//    byte[] dll_data = new byte[sm.Length];
			//    sm.Read(dll_data, 0, dll_data.Length);
			//    sm.Close();

			//    FileStream file_writer = new FileStream(dll_file, FileMode.Create);
			//    file_writer.Write(dll_data, 0, dll_data.Length);
			//    file_writer.Close();
			//}

			dll_file = Directory.GetCurrentDirectory() + "\\canlibCLSNET.dll";
			if (File.Exists(dll_file) == false)
			{
				Stream sm = Assembly.GetExecutingAssembly().GetManifestResourceStream("CANMonitor.canlibCLSNET.dll");
				byte[] dll_data = new byte[sm.Length];
				sm.Read(dll_data, 0, dll_data.Length);
				sm.Close();

				FileStream file_writer = new FileStream(dll_file, FileMode.Create);
				file_writer.Write(dll_data, 0, dll_data.Length);
				file_writer.Close();
			}

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}
